{include file="common/_meta" /}

<title>新建网站角色 - 管理员管理 - H-ui.admin v3.1</title>
<meta name="keywords" content="H-ui.admin v3.1,H-ui网站后台模版,后台模版下载,后台管理系统模版,HTML后台模版下载">
<meta name="description" content="H-ui.admin v3.1，是一款由国人开发的轻量级扁平化网站后台模板，完全免费开源的网站后台管理系统模版，适合中小型CMS后台系统。">
</head>
<body>
<article class="page-container">
	<form  class="form form-horizontal" id="form-role-add">
		<div class="row cl">
			<label class="form-label col-xs-4 col-sm-3">权限名称：</label>
			<div class="formControls col-xs-8 col-sm-9">
				<input type="text" class="input-text" value="" placeholder="" name="title">
			</div>
		</div>
		<div class="row cl">
			<label class="form-label col-xs-4 col-sm-3">规则标识：</label>
			<div class="formControls col-xs-8 col-sm-9">
				<input type="text" class="input-text" value="" placeholder="" id="" name="rolename">
				形式为admin/admin/index
			</div>
		</div>
		<div class="row cl">
			<label class="form-label col-xs-4 col-sm-3">上级菜单</label>
			<div class="formControls col-xs-8 col-sm-9"> <span class="select-box" style="width:150px;">
			<select class="select"  size="1" name="pid">
				<option value="0" selected="">无</option>
				{volist name="rules" id="vol"}
				<option value="{$vol['id']}">
				{if condition="$vol['pid'] != 0"}
					{$vol['level']|str_repeat='-',###*2}{$vol['title']}
				{else /}
					{$vol['title']}
				{/if}
				</option>
				{/volist}
				
			</select>
			</span> </div>
		</div>  
		
		<div class="row cl">
			<div class="col-xs-8 col-sm-9 col-xs-offset-4 col-sm-offset-3">
				<a class="btn btn-success radius" onclick="ajaxsubmit();"> 确定</a>
			</div>
		</div>
	</form>
</article>

{include file="common/_footer" /}


<script type="text/javascript">
function ajaxsubmit(){
		$.ajax({
			type:'post',
			url:'{:url('admin/admin/permission_add')}',
			dataType:'json',
			data: $('#form-role-add').serialize(),
			success: function(data){
				if(data.code !== 200){
					layer.alert(data.msg, {icon: data.icon});
				}else{
					layer.msg(data.msg,{icon:data.icon,time:1000},function(){
					window.parent.location.reload();
					var index = parent.layer.getFrameIndex(window.name);
					parent.layer.close(index);
					});
				}
			},
            error: function(XmlHttpRequest, textStatus, errorThrown){
            	console.log(XmlHttpRequest, textStatus, errorThrown);
				layer.alert('规则标识已存在!', {icon: 2});
			}
		});
	}
</script>
<!--/请在上方写此页面业务相关的脚本-->
</body>
</html>